class Solution(object):
    def maximumTop(self, nums, k):
        nums = [[num, index] for index, num in enumerate(nums)]
        nums.sort(reverse=True)
        print(nums)
        for num, index in nums:
            if k >= index:
                if (k - index) % 2 == 0:
                    return num
                else:
                    if k - index > 1 and len(nums) >= 2:
                        return num
        return -1


data = Solution()
nums = [73, 63, 62, 16, 95, 92, 93, 52, 89, 36, 75, 79, 67, 60, 42, 93, 93, 74, 94, 73, 35, 86, 96]
k = 59
print(data.maximumTop(nums, k))
